package com.foredu.fiqs.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.foredu.fiqs.domain.Employee;
import com.foredu.fiqs.domain.Salary;
import com.foredu.fiqs.domain.SalaryItem;
import com.foredu.fiqs.domain.SalaryItemDetail;
import com.foredu.fiqs.domain.SalaryItemDetailType;
import com.foredu.fiqs.domain.SalaryItemType;
import com.foredu.fiqs.persist.IEmployeeDao;
import com.foredu.fiqs.persist.ISalaryDao;
import com.foredu.fiqs.persist.ISalaryItemDao;
import com.foredu.fiqs.persist.ISalaryItemDetailDao;
import com.foredu.fiqs.persist.ISalaryItemDetailTypeDao;
import com.foredu.fiqs.persist.ISalaryItemTypeDao;
import com.foredu.fiqs.service.IDataImportService;

@Transactional
public class DataImportService implements IDataImportService {

	private ISalaryDao salaryDao;
	private ISalaryItemDao salaryItemDao;
	private ISalaryItemTypeDao salaryItemTypeDao;
	private ISalaryItemDetailDao salaryItemDetailDao;
	private ISalaryItemDetailTypeDao salaryItemDetailTypeDao;
	private IEmployeeDao employeeDao;

	/*
	 * 各个领域模型类的业务逻辑处理方法
	 */
	@Override
	public void deleteSalaryById(int id) {
		Salary salary = salaryDao.findById(id);
		salaryDao.delete(salary);
	}

	@Override
	public void deleteSalaryItemById(int id) {
		SalaryItem item = salaryItemDao.findById(id);
		salaryItemDao.delete(item);
	}

	@Override
	public void deleteSalaryItemDetailById(int id) {
		SalaryItemDetail itemDetail = salaryItemDetailDao.findById(id);
		salaryItemDetailDao.delete(itemDetail);
	}

	@Override
	public void deleteSalaryItemDetailTypeById(int id) {
		SalaryItemDetailType type = salaryItemDetailTypeDao.findById(id);
		salaryItemDetailTypeDao.delete(type);
	}

	@Override
	public void deleteSalaryItemTypeById(int id) {
		SalaryItemType type = salaryItemTypeDao.findById(id);
		salaryItemTypeDao.delete(type);
	}

	@Override
	public List<Salary> findSalaries() {
		return salaryDao.findAll();
	}

	@Override
	public Salary findSalaryById(int id) {
		return salaryDao.findById(id);
	}

	@Override
	public SalaryItem findSalaryItemById(int id) {
		return salaryItemDao.findById(id);
	}

	@Override
	public SalaryItemDetail findSalaryItemDetailById(int id) {
		return salaryItemDetailDao.findById(id);
	}

	@Override
	public SalaryItemDetailType findSalaryItemDetailTypeById(int id) {
		return salaryItemDetailTypeDao.findById(id);
	}

	@Override
	public List<SalaryItemDetailType> findSalaryItemDetailTypes() {
		return salaryItemDetailTypeDao.findAll();
	}

	@Override
	public List<SalaryItemDetail> findSalaryItemDetails() {
		return salaryItemDetailDao.findAll();
	}

	@Override
	public SalaryItemType findSalaryItemTypeById(int id) {
		return salaryItemTypeDao.findById(id);
	}

	@Override
	public List<SalaryItemType> findSalaryItemTypes() {
		return salaryItemTypeDao.findAll();
	}

	@Override
	public List<SalaryItem> findSalaryItems() {
		return salaryItemDao.findAll();
	}

	@Override
	public void saveSalary(Salary salary) {
		salaryDao.save(salary);
	}

	@Override
	public void saveSalaryItem(SalaryItem salaryItem) {
		salaryItemDao.save(salaryItem);
	}

	@Override
	public void saveSalaryItemDetail(SalaryItemDetail salaryItemDetail) {
		salaryItemDetailDao.save(salaryItemDetail);
	}

	@Override
	public void saveSalaryItemDetailType(SalaryItemDetailType salaryItemDetailType) {
		salaryItemDetailTypeDao.save(salaryItemDetailType);
	}

	@Override
	public void saveSalaryItemType(SalaryItemType salaryItemType) {
		salaryItemTypeDao.save(salaryItemType);
	}

	@Override
	public void updateSalary(Salary salary) {
		salaryDao.update(salary);
	}

	@Override
	public void updateSalaryItem(SalaryItem salaryItem) {
		salaryItemDao.update(salaryItem);
	}

	@Override
	public void updateSalaryItemDetail(SalaryItemDetail salaryItemDetail) {
		salaryItemDetailDao.update(salaryItemDetail);
	}

	@Override
	public void updateSalaryItemDetailType(SalaryItemDetailType salaryItemDetailType) {
		salaryItemDetailTypeDao.update(salaryItemDetailType);
	}

	@Override
	public void updateSalaryItemType(SalaryItemType salaryItemType) {
		salaryItemTypeDao.update(salaryItemType);
	}

	@Override
	public void deleteEmployeeById(int id) {
		Employee employee = employeeDao.findById(id);
		employeeDao.delete(employee);		
	}

	@Override
	public Employee findEmployeeById(int id) {
		return employeeDao.findById(id);
	}

	@Override
	public List<Employee> findEmployees() {
		return employeeDao.findAll();
	}

	@Override
	public void saveEmployee(Employee employee) {
		employeeDao.save(employee);
	}

	@Override
	public void updateEmployee(Employee employee) {
		employeeDao.update(employee);
	}

	@Override
	public Employee findEmployeeByEmpId(String empId) {
		return employeeDao.findByEmpId(empId);
	}
	
	/*
	 * 各个DAO的get/set方法
	 */
	public ISalaryDao getSalaryDao() {
		return salaryDao;
	}

	public void setSalaryDao(ISalaryDao salaryDao) {
		this.salaryDao = salaryDao;
	}

	public ISalaryItemDao getSalaryItemDao() {
		return salaryItemDao;
	}

	public void setSalaryItemDao(ISalaryItemDao salaryItemDao) {
		this.salaryItemDao = salaryItemDao;
	}

	public ISalaryItemTypeDao getSalaryItemTypeDao() {
		return salaryItemTypeDao;
	}

	public void setSalaryItemTypeDao(ISalaryItemTypeDao salaryItemTypeDao) {
		this.salaryItemTypeDao = salaryItemTypeDao;
	}

	public ISalaryItemDetailDao getSalaryItemDetailDao() {
		return salaryItemDetailDao;
	}

	public void setSalaryItemDetailDao(ISalaryItemDetailDao salaryItemDetailDao) {
		this.salaryItemDetailDao = salaryItemDetailDao;
	}

	public ISalaryItemDetailTypeDao getSalaryItemDetailTypeDao() {
		return salaryItemDetailTypeDao;
	}

	public void setSalaryItemDetailTypeDao(ISalaryItemDetailTypeDao salaryItemDetailTypeDao) {
		this.salaryItemDetailTypeDao = salaryItemDetailTypeDao;
	}

	public IEmployeeDao getEmployeeDao() {
		return employeeDao;
	}
	
	public void setEmployeeDao(IEmployeeDao employeeDao) {
		this.employeeDao = employeeDao;
	}

}
